package com.dotflat.survey.dto;

import com.dotflat.rest.domain.AreableObjectBase;
import com.dotflat.survey.domain.SurveyAnswer;
import com.matt.commons.exception.BusinessException;
import com.matt.foundation.model.ErrorCode;
import com.tuo51.foudation.utils.CopyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("答卷列表条目")
public class SurveyAnswerDTO extends AreableObjectBase {

    @ApiModelProperty("问卷id")
    private String sheetId;

    @ApiModelProperty("家长id")
    private String parentId;

    @ApiModelProperty("宝宝id")
    private String childId;

    public static SurveyAnswerDTO of(SurveyAnswer sheet){
        if (sheet == null){
            throw new BusinessException(ErrorCode.PARAM_CAN_NOT_BLANK, "对象为空");
        }

        SurveyAnswerDTO ret = new SurveyAnswerDTO();

        CopyUtils.copyProperties(sheet, ret);

        return ret;
    }
}
